﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CheckedUncheckedExample
{
    class Program
    {
        static void Main(string[] args)
        {
            //Unchecked block.
            int ten = 10;
            int i2 = 2147483647 + ten;

            Console.WriteLine("This is unchecked value of purposefully overloaded int: \n" + i2);

            //This evokes an exception
            //Console.WriteLine(checked(2147483647 + ten));

            // Uhecked this and this will evoke an exception:
            unchecked
            {
                short five = 32767;
                short s1 = Convert.ToInt16(Int16.MinValue + five);
                Console.WriteLine("This is attempt to overload MinValue ("+ Int16.MinValue + ") " + "short:\n" +
                    "but all we've got for now is shifted short value: \n" + s1);
            }

        }
    }
}
